﻿<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../helpproject.xsl" ?>
<topic template="Default" lasteditedby="Geert" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../helpproject.xsd">
  <title translate="true">Naming conventions</title>
  <keywords>
    <keyword translate="true">Naming conventions</keyword>
  </keywords>
  <body>
    <header>
      <para styleclass="Heading1"><text styleclass="Heading1" translate="true">Naming conventions</text></para>
    </header>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Some services in Catel support naming conventions. For example, the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_IViewLocator" styleclass="Normal" translate="true">IViewLocator</link><text styleclass="Normal" translate="true"> and </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_IViewModelLocator" styleclass="Normal" translate="true">IViewModelLocator</link><text styleclass="Normal" translate="true"> allow naming conventions to prevent a user from having to register all views and view models. Internally, the naming conventions are resolved using the </text><link displaytype="text" defaultstyle="true" type="topiclink" href="T_Catel_MVVM_Services_NamingConvention" styleclass="Normal" translate="true">NamingConvention</link><text styleclass="Normal" translate="true"> helper class. This part of the documentation explains the possible constants in naming conventions.</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">[AS] constant</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">The </text><text styleclass="Normal" style="font-style:normal;" translate="true">[AS]</text><text styleclass="Normal" translate="true"> constant will be replaced by the assembly name. For example, the following naming convention:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">[AS].Views</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">in assembly </text><text styleclass="Normal" style="font-style:italic;" translate="true">Catel.Examples </text><text styleclass="Normal" translate="true">will be resolved as:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" translate="true">Catel.Examples.Views</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">[VM] constant</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">The [VM] constant will be replaced by the name of the view model without the </text><text styleclass="Normal" style="font-style:italic;" translate="true">ViewModel</text><text styleclass="Normal" style="font-style:normal;" translate="true"> postfix. For example, the following naming convention:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">[AS].Views.[VM]View</text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">in assembly </text><text styleclass="Normal" style="font-weight:normal; font-style:italic; color:#000000;" translate="true">Catel.Examples</text><text styleclass="Normal" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> and for type </text><text styleclass="Normal" style="font-weight:normal; font-style:italic; color:#000000;" translate="true">Catel.Examples.ViewModels.MyViewModel</text><text styleclass="Normal" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> will be resolved as:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">Catel.Examples.Views.MyView</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">[VW] constant</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">The [VW] constant will be replaced by the name of the view without the </text><text styleclass="Normal" style="font-style:italic;" translate="true">View, Control, Page or Window</text><text styleclass="Normal" style="font-style:normal;" translate="true"> postfixes. For example, the following naming convention:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">[AS].ViewModels.[VM]ViewModel</text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">in assembly </text><text styleclass="Normal" style="font-weight:normal; font-style:italic; color:#000000;" translate="true">Catel.Examples</text><text styleclass="Normal" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> and for type </text><text styleclass="Normal" style="font-weight:normal; font-style:italic; color:#000000;" translate="true">Catel.Examples.Views.MyView</text><text styleclass="Normal" style="font-weight:normal; font-style:normal; color:#000000;" translate="true"> will be resolved as:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">Catel.Examples.ViewModels.MyViewModel</text></para>
    <para styleclass="Heading1"><text styleclass="Heading1" translate="true">[UP] constant</text></para>
    <para styleclass="Normal"><text styleclass="Normal" translate="true">Sometimes it is not possible to use the [AS] constant because the assembly name does is not used in the namespace. For example, for an application called </text><text styleclass="Normal" style="font-style:italic;" translate="true">PersonApplication</text><text styleclass="Normal" translate="true"> where the client assembly is </text><text styleclass="Normal" style="font-style:italic;" translate="true">PersonApplication.Client</text><text styleclass="Normal" style="font-style:normal;" translate="true">, the root namespace will still be </text><text styleclass="Normal" style="font-style:italic;" translate="true">PersonApplication</text><text styleclass="Normal" style="font-style:normal;" translate="true">. Therefore, it is recommend to use the [UP] constant for this situation.</text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-style:normal;" translate="true">The [UP] constant will move the namespaces up by one step. It automatically detects the right separator (\ (backslash), / (slash), . (dot) and | (pipe) are supported).</text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-style:normal;" translate="true">The following naming convention:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">[UP].Views.[VM]View</text></para>
    <para styleclass="Normal"><text styleclass="Normal" style="font-style:normal;" translate="true">for type Catel.Examples.ViewModels.MyViewModel will be resolved as:</text></para>
    <para styleclass="Code Example"><text styleclass="Code Example" style="font-weight:normal; font-style:normal; color:#000000;" translate="true">Catel.Examples.Views.MyView</text></para>
  </body>
</topic>
